import Types from "./config.js"

export default Component({
  behaviors: [],
  properties: {
    type: {
      type: String,
      value: "",
      observer(type) {
        if (type && Types[type]) {
          let image = this.data.image || Types[type].image
          let title = this.data.title || Types[type].title
          // let button = this.data.button || Types[type].button
          let tip = this.data.tip || Types[type].tip
          this.setData({
            image,
            title,
            // button,
            tip
          })
        }
      }
    },
    image: {
      type: String,
      value: ""
    },
    vclass: {
      type: String,
      value: ""
    },
    paddingBottom: {
      type: String,
      value: "150%"
    },
    title: {
      type: String,
      value: ""
    },
    tip: {
      type: String,
      value: ""
    }
  },
  data: {
    showStatus: true,
    imgWidth: 0,
    imgHeight: 0,
  },
  methods: {
    maskClick(){
      this.triggerEvent("clickMask")
    },
    getImgWidth(e) {
      let { width, height } = e.detail
      this.setData({
        imgWidth: width / 1.5,
        imgHeight: height / 1.5,
      })
    },
    show() {
      this.setData({
        showStatus: true
      })
    },
    hide() {
      this.setData({
        showStatus: false
      })
    }
  }
})
